<?php

namespace App\Http\Controllers\Index;

use App\Console\Commands\HbSub;
use App\hbSocket\SubscribeClient;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\hbSocket\RequestClient;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;

class IndexController extends BaseController
{
    public function index()
    {
        $ex=DB::table('exchange')->get();
        return view('home/index',compact('ex'));
    }
    
    //查询币种
    public function selCurr(Request $request)
    {
        $ex_id=$request->ex;
       $data=DB::table('exchange')->where(['ex_id'=>$ex_id])->value('currency');
       if(strpos($data,',')){
          $curr=explode(',',$data);
       }else{
           $curr=$data;
       }
       return $this->success('',$curr);
    }
    //查看交易记录
    public function orderLog($ex,$curr)
    {
        $list=DB::table('order_log')->where(['ex_id'=>$ex,'curr'=>$curr])->get();
        return view('home/exchange-record',compact('list'));
    }
}
